package com.kyle.redpacket;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.ReactiveHashOperations;
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
import reactor.core.publisher.Mono;

@SpringBootTest
public class RedisDemoApplication {
    @Autowired
    private ReactiveStringRedisTemplate redisTemplate;

    /*@Bean
    ReactiveStringRedisTemplate reactiveRedisTemplate(ReactiveRedisConnectionFactory factory) {
        return new ReactiveStringRedisTemplate(factory);
    }*/
    @Test
    public void run() {
        ReactiveHashOperations<String, String, String> hashOps = redisTemplate.opsForHash();
        Mono<Boolean> mono1 = hashOps.put("apple", "x", "6000");
        mono1.subscribe(System.out::println);
        Mono<Boolean> mono2 = hashOps.put("apple", "xr", "5000");
        mono2.subscribe(System.out::println);
        Mono<Boolean> mono3 = hashOps.put("apple", "xs max", "8000");
        mono3.subscribe(System.out::println);
    }
}